package com.jackstraw.jack_base.datasource.elasticsearch.repository;

import co.elastic.clients.elasticsearch._types.FieldValue;
import co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery;
import co.elastic.clients.json.JsonData;
import com.jackstraw.jack_base.datasource.elasticsearch.entity.Zoo;
import com.jackstraw.jack_base.datasource.elasticsearch.entity.Zoo;
import com.jackstraw.jack_base.datasource.elasticsearch.entity.bean.ElasticSearchRouting;
import com.jackstraw.jack_base.util.CollectionUtil;
import com.jackstraw.jack_base.util.DateTimeUtil;
import com.jackstraw.jack_base.util.ObjectUtil;
import com.jackstraw.jack_base.util.StringUtil;
import com.jackstraw.jack_base.util.function.ReflectionUtil;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

public class ZooElasticsearchRepository extends ElasticsearchRepository<Zoo> {


    public ZooElasticsearchRepository(ElasticSearchRouting elasticSearchRouting, Class<Zoo> entityClass) {
        super(elasticSearchRouting, entityClass);
    }

    @Override
    public BoolQuery.Builder boolQueryBuilder(Zoo entity, BoolQuery.Builder boolQueryBuilder) {
        //条件判断（若没有条件时，抛出异常）
        Boolean queryFlag = Boolean.TRUE;
        boolQueryBuilder = super.boolQueryBuilder(entity, boolQueryBuilder);
        if (ObjectUtil.ObjectUtilByLang3.isEmpty(boolQueryBuilder)) {
            queryFlag = Boolean.FALSE;
            boolQueryBuilder = new BoolQuery.Builder();
        }


        return queryFlag ? boolQueryBuilder : null;
    }
}
